package bean;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToOne;
import javax.persistence.Table;

import org.hibernate.annotations.NamedQueries;
import org.hibernate.annotations.NamedQuery;

@Entity
@Table
@NamedQueries(value = { 
	@NamedQuery(name="CompactDisc.findbyName", query="select c from CompactDisc c where c.name =:name"),
	@NamedQuery(name="CompactDisc.findAll", query="select c from CompactDisc c"),
	@NamedQuery(name="CompactDisc.findbyId", query="select c from CompactDisc c where c.id =:id"),
})
public class CompactDisc implements java.io.Serializable{
	private static final long serialVersionUID = 1L;
	private Long cdId;
	private String name;
	private Producer producer;
	private TypeCD cdType;
	private Date insertDate;
	private Date acquisitionDate;

	public CompactDisc() {}

	public CompactDisc(String name, Producer producer, TypeCD cdType) {
		this.name = name;
		this.producer = producer;
		this.cdType = cdType;
	}
	
	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	@Column(name="id")
	public Long getCdId() {
		return cdId;
	}
	public void setCdId(Long cdId) {
		this.cdId = cdId;
	}
	
	@Column
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	
	@OneToOne
	@JoinColumn(name="producer_id")
	public Producer getProducer() {
		return producer;
	}
	public void setProducer(Producer producer) {
		this.producer = producer;
	}
	
	@OneToOne
	@JoinColumn(name="type_id")
	public TypeCD getCdType() {
		return cdType;
	}
	public void setCdType(TypeCD cdType) {
		this.cdType = cdType;
	}
	
	@Column
	public Date getInsertDate() {
		return insertDate;
	}
	public void setInsertDate(Date insertDate) {
		this.insertDate = insertDate;
	}
	
	@Column
	public Date getAquisitionDate() {
		return acquisitionDate;
	}
	public void setAquisitionDate(Date acquisitionDate) {
		this.acquisitionDate = acquisitionDate;
	}
}
